package com.example.androiddemo;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.ex.views.AbsItem;
import com.example.androiddemo.GalleryItem.ViewHolder;

public class GalleryItem extends AbsItem<ViewHolder>{
	
	private int resId;
	
	public GalleryItem(Context ctx, int imageResId) {
		super(ctx);
		resId = imageResId;
	}

	static class ViewHolder {
		ImageView imageView;
	}

	@Override
	public View initViews(Context context, int position, ViewGroup parent) {
		View view = LayoutInflater.from(context).inflate(R.layout.gallery_item, null);
		return view;
	}

	@Override
	public ViewHolder initViewHolder(View view) {
		ViewHolder vh = new ViewHolder();
		vh.imageView = (ImageView) view.findViewById(R.id.item);
		return vh;
	}

	@Override
	public void updateViews(View view, ViewHolder vh, int position,
			ViewGroup parent) {
		vh.imageView.setImageResource(resId);
	}

}
